import actionType from '../actions/actionTypes'
const initState = {
    id: '',
    displayName: '',
    avatar: '',
    role: '',
    isLogin: false,
    isLoading: false
}

export default (state=initState, actions) => {
    switch (actions.type) {
        case actionType.SUCCESS_LOGIN:
            return {
                ...state,
                ...actions.payload.userInfo,
                isLoading: false,
                isLogin:true
            }
        case actionType.START_LOGIN:
            return {
                ...state,
                isLoading: true
            }
        case  actionType.FALID_LOGIN:
            return initState;
        default:
            return state;
    }
}